package com.jacky.javafx;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class TableViewApplication extends Application {

    public static ConfigurableApplicationContext ctx;
    public static void main(String[] args) {
        launch();
        SpringApplication.run(TableViewApplication.class,args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        ctx = SpringApplication.run(TableViewApplication.class);
        FXMLLoader root = new FXMLLoader(getClass().getResource("/com/jacky/javafx/tableview.fxml"));
        root.setControllerFactory(ctx::getBean);

        Scene scene = new Scene(root.load());
        primaryStage.setTitle("TableView");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
